package com.ticket.web.controller.yanchu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ticket.system.service.IYanchuScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ticket.common.annotation.Log;
import com.ticket.common.core.controller.BaseController;
import com.ticket.common.core.domain.AjaxResult;
import com.ticket.common.enums.BusinessType;
import com.ticket.system.domain.TYanchuPointsRule;
import com.ticket.system.service.ITYanchuPointsRuleService;
import com.ticket.common.utils.poi.ExcelUtil;
import com.ticket.common.core.page.TableDataInfo;

/**
 * 积分规则Controller
 * 
 * @author ruoyi
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/system/points/rule")
@Api(tags = "积分pc管理")
public class TYanchuPointsRuleController extends BaseController
{
    @Autowired
    private ITYanchuPointsRuleService tYanchuPointsRuleService;
    @Autowired
    private IYanchuScoreService iYanchuScoreService;


    /**
     * 查询积分规则列表
     */
    @PreAuthorize("@ss.hasPermi('system:rule:list')")
    @GetMapping("/list")
    @ApiOperation("查询列表")
    public TableDataInfo list(TYanchuPointsRule tYanchuPointsRule)
    {
        startPage();
        List<TYanchuPointsRule> list = tYanchuPointsRuleService.selectTYanchuPointsRuleList(tYanchuPointsRule);
        return getDataTable(list);
    }

    /**
     * 导出积分规则列表
     */
    @PreAuthorize("@ss.hasPermi('system:rule:export')")
    @Log(title = "积分规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出")
    public void export(HttpServletResponse response, TYanchuPointsRule tYanchuPointsRule)
    {
        List<TYanchuPointsRule> list = tYanchuPointsRuleService.selectTYanchuPointsRuleList(tYanchuPointsRule);
        ExcelUtil<TYanchuPointsRule> util = new ExcelUtil<TYanchuPointsRule>(TYanchuPointsRule.class);
        util.exportExcel(response, list, "积分规则数据");
    }

    /**
     * 获取积分规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rule:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("详情")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tYanchuPointsRuleService.selectTYanchuPointsRuleById(id));
    }

    /**
     * 新增积分规则
     */
    @PreAuthorize("@ss.hasPermi('system:rule:add')")
    @Log(title = "积分规则", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增")
    public AjaxResult add(@RequestBody TYanchuPointsRule tYanchuPointsRule)
    {
        return toAjax(tYanchuPointsRuleService.insertTYanchuPointsRule(tYanchuPointsRule));
    }

    /**
     * 修改积分规则
     */
    @PreAuthorize("@ss.hasPermi('system:rule:edit')")
    @Log(title = "积分规则", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改")
    public AjaxResult edit(@RequestBody TYanchuPointsRule tYanchuPointsRule)
    {
        return toAjax(tYanchuPointsRuleService.updateTYanchuPointsRule(tYanchuPointsRule));
    }

    /**
     * 删除积分规则
     */
    @PreAuthorize("@ss.hasPermi('system:rule:remove')")
    @Log(title = "积分规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tYanchuPointsRuleService.deleteTYanchuPointsRuleByIds(ids));
    }





}
